package api

import (
	"blogdemo/gin/errmsg"
	"blogdemo/gin/model"
	"github.com/gin-gonic/gin"
	"net/http"
)

// WriteComment 添加评论
func WriteComment(c *gin.Context) {
	var comment model.Comment
	_ = c.ShouldBindJSON(&comment)

	msgCode := model.CreateComment(&comment)

	c.JSON(http.StatusOK, gin.H{
		"status":  msgCode,
		"message": errmsg.GetErrMsg(msgCode),
	})
}
